package org.orr.budgetpro.entities;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.format.annotation.NumberFormat;
import org.springframework.format.annotation.NumberFormat.Style;

@Entity
public class IncomeItem implements BudgetItem, Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue
	Integer incomeItemId;

	@NotBlank
	@Length(max = 20)
	private String description;

	@Min(1)
	@NotNull
	@NumberFormat(pattern="#,###")
	private Integer amount;

	@ManyToOne
	private Budget budget;

	public IncomeItem() {
		super();
	}

	public IncomeItem(Integer incomeItemId, String description, Integer amount) {
		super();
		this.incomeItemId = incomeItemId;
		this.description = description;
		this.amount = amount;
		this.budget = budget;
	}

	public Integer getIncomeItemId() {
		return incomeItemId;
	}

	public void setIncomeItemId(Integer incomeItemId) {
		this.incomeItemId = incomeItemId;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setAmount(Integer amount) {
		this.amount = amount;
	}

	@Override
	public String getDescription() {
		return description;
	}

	@Override
	public Integer getAmount() {
		return amount;
	}

	public Budget getBudget() {
		return budget;
	}

	public void setBudget(Budget budget) {
		this.budget = budget;
	}

	@Override
	public String toString() {
		return "IncomeItem [incomeItemId=" + incomeItemId + ", description="
				+ description + ", amount=" + amount + "]";
	}

}
